using UnityEngine;
using System.Collections;

/// <summary>
/// Spins an object and bobs it up and down. Meant for items.
/// </summary>
public class SpinAndBob : MonoBehaviour {

	public float spinSpeed = 2f;
	public float bobSpeed = 3f;
	public float bobAmount = 0.5f;
	
	// Use this for initialization
	void Start () {
		Spin();
		Bob();
	}
	
	void Spin() {
		//iTween.RotateBy(gameObject, iTween.Hash ("amount", 1f, "time", spinSpeed, "looptype", iTween.LoopType.loop));
		transform.Rotate(new Vector3(0,1,0) * spinSpeed * Time.deltaTime);
	}
	
	void Bob() {
		iTween.MoveBy(gameObject, iTween.Hash ("y", bobAmount, "speed", bobSpeed, "looptype", iTween.LoopType.pingPong, "easetype", iTween.EaseType.easeInOutSine));
	}
	
	// Update is called once per frame
	void Update () {
		//transform.Rotate(new Vector3(0,1,0) * spinSpeed * Time.deltaTime);
		Spin ();
	}
}
